﻿using KMF.Common;
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Text;

namespace KMF.DAL
{
    public partial class ProductHotDb
    {
        public static List<ProductRateByCateTopListPagingDto> GetListAllProductHotHome(int page, int itemsPerPage,
                                                                                    ref int totalPage)
        {
            var dao = SharedSqlDao;
            var command = dao.GetDbSprocCommand("WSPX_Home_ProductHot_GetAllPagging");
            try
            {
                command.Parameters.Add(dao.CreateParameter("@Page", page));
                command.Parameters.Add(dao.CreateParameter("@ItemsPerPage", itemsPerPage));
                SqlParameter outTotalpage = command.Parameters.Add("@TotalPage", SqlDbType.Int);
                outTotalpage.Direction = ParameterDirection.Output;
                var result = dao.GetDTOList<ProductRateByCateTopListPagingDto>(ref command);

                totalPage = int.Parse(outTotalpage.Value.ToString() == "" ? "0" : outTotalpage.Value.ToString());

                return result;
            }
            finally
            {
                command.Connection.Close();
            }
        }
    }
}
